home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ASME's Mechanical Engine…ing Toolkit 1997 December
/
ASME's Mechanical Engineering Toolkit 1997 December.iso
/
c_lang
/
varinc.lzh
/
PAGE29.C
< prev
next >
Wrap
C/C++ Source or Header
|
1979-11-30
|
644b
|
17 lines
/* Convert a short int copy of -3 to other integral types. */
main()
{
short short_var = -3;
unsigned short uns_short_var = short_var;
char char_var = short_var; /* Truncate: 2 bytes to 1. */
unsigned char uns_char_var = short_var;
long long_var = short_var; /* Widen: 2 bytes to 4. */
unsigned long uns_long_var = short_var;
printf("short_var = %d, uns_short_var = %u\n", short_var, uns_short_var);
printf("char_var = %d, uns_char_var = %u\n", char_var, uns_char_var);
printf("long_var = %ld, uns_long_var = %lu\n", long_var, uns_long_var);
}